package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.Accounts;
import com.zygh.policeasset.pojo.Settlement;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AccountsMapper {


    @Insert("insert into accounts (project_no,audit_time,create_time,description) values " +
            "(#{projectNo},#{auditTime},#{createTime},#{description})")
    int add(Accounts accounts);


    @Select(" <script>select *  from accounts <where>  " +
            "<if test='projectNo != null and projectNo.length &gt; 0'>  project_no=#{projectNo} </if>" +
            "<if test='startTime != null and startTime.length &gt;0 and endTime != null and endTime.length &gt;0'>and audit_time between #{startTime} and #{endTime}</if> "  +
            " </where></script>")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "projectNo",column = "project_no"),
            @Result(property = "auditTime",column = "audit_time"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "description",column = "description"),
    })
    List<Accounts> findAll(Accounts accounts);

    @Select("select *  from accounts where id = #{id}")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "projectNo",column = "project_no"),
            @Result(property = "auditTime",column = "audit_time"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "description",column = "description"),
    })
    Accounts selectById(Integer id);

    @Update("update accounts set project_no = #{projectNo},audit_time =#{auditTime},create_time = #{createTime},description=#{description}" +
            " where id = #{id}")
    int update(Accounts accounts);

    @Delete("delete from accounts where id = #{id}")
    int delete(Integer id);



}
